package com.cw.kafka.starter.controller;

import java.util.Date;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cw.kafka.starter.constant.KafkaMessageDto;
import com.cw.kafka.starter.producer.KafkaProducer;

/**
 * TODO
 *
 * @author chenw
 * @date 2021/1/18
 */
@RestController
@RequestMapping("")
public class KafkaController {
    @Autowired
    private KafkaProducer kafkaProducer;
    @RequestMapping("testSendKafka")
    public void send(){
        KafkaMessageDto kafkaMessageDto = new KafkaMessageDto();
        kafkaMessageDto.setMessage("hello kafka");
        kafkaMessageDto.setSerialNo(UUID.randomUUID().toString());
        kafkaMessageDto.setIdemSerialNo(UUID.randomUUID().toString());
        kafkaMessageDto.setTradeDate(new Date());
        kafkaProducer.send("demo_topic",kafkaMessageDto);
    }
}
